<?php
	load_plugin_textdomain('codelog', 'wp-content/themes/codelog/lang');
	get_header();
?>
<div id="content">

<?php if( !is_ads_free() ): ?>
<div class="post">
<script type="text/javascript"><!--
google_ad_client = "<?php google_pub_id();?>";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "FF3300";
google_color_text = "000000";
google_color_url = "999999";
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--
google_ad_client = "<?php google_pub_id();?>";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "FF3300";
google_color_text = "000000";
google_color_url = "999999";
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
<?php endif; ?>

<?php if (have_posts()) :
	if ( is_archive() ){
		if ( is_category() )
			echo '<div class="pagetitle"><h2 class="pagetitle">'.sprintf( __("Archive for the category &#8220;%s&#8221;", 'codelog'), single_cat_title('', false) ).'</h2></div>';

		elseif ( is_year() )
			echo '<div class="pagetitle"><h2 class="pagetitle">'.sprintf( __("Archive for %s", 'codelog'), get_the_time(__('Y', 'codelog')) ).'</h2></div>';

		elseif ( is_month() )
			echo '<div class="pagetitle"><h2 class="pagetitle">'.sprintf( __("Archive for %s", 'codelog'), get_the_time(__('F, Y', 'codelog')) ).'</h2></div>';

		elseif ( is_day() )
			echo '<div class="pagetitle"><h2 class="pagetitle">'.sprintf( __("Archive for %s", 'codelog'), get_the_time(__('F jS, Y', 'codelog')) ).'</h2></div>';

		elseif (is_search())
			echo '<div class="pagetitle"><h2 class="pagetitle">'.__("Search Results", 'codelog').'</h2></div>';

		elseif (is_author())
			echo '<div class="pagetitle"><h2 class="pagetitle">'.__("Author Archive", 'codelog').'</h2></div>';
	}
	?>

	<?php while (have_posts()) : the_post(); ?>
	
		<div class="post" id="post-<?php the_ID(); ?>">

			<?php if ( !is_page() ) { echo "<span class='subtitle'>".sprintf( __('%1$s at %2$s', 'codelog'), get_the_time(__('F jS, Y', 'codelog')), get_the_time(__('g:i a', 'codelog') ) )."</span>"; } ?>
			
			<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e("Permanent link to", 'codelog') ?> <?php the_title() ?>"><?php the_title() ?></a></h2>

			<div class="entry">
				<?php the_content('<span class="morelink">'.__("More &raquo;", 'codelog').'</span>'); ?>
			</div>
			<?php edit_post_link(__('Edit this post', 'codelog'), '', ''); ?>

				<p class="postmetadata">
					<?php
					$feed_link = rtrim(get_permalink(), '/');
					$feed_link .= (strpos($feed_link, '?') === false) ? '/feed' : '&amp;feed=rss2';
					if ( is_single() || is_page() )
						echo '<span class="pm_right"><a href="'.$feed_link.'"><img src="'.get_bloginfo('stylesheet_directory').'/images/commentsfeed.png" alt="'.__("Feed for this post", 'codelog').'" title="'.__("Subscribe to comments on this post", 'codelog').'" /></a></span>';
					else
					{
						$c1 = '<span class="pm_right"><span><img src="'. get_bloginfo('stylesheet_directory').'/images/comments.png" alt="'.__("Comments:", 'codelog').'" title="'.__("Comments", 'codelog').'" /></span>&nbsp;';
						$c2 = '</span>';
						comments_popup_link("{$c1}0{$c2}", "{$c1}1{$c2}", "{$c1}%{$c2}");
					}
					?>
					<?php if ( !is_page() ) : ?>
					
						<span><img src="<?php bloginfo('stylesheet_directory') ?>/images/folder.png" alt="<?php _e("Categories:", 'codelog') ?>" title="<?php _e("Categories", 'codelog') ?>" />&nbsp;<?php the_category(', ') ?></span>

						<?php if (function_exists('get_the_tag_list') && $tags = get_the_tag_list('', ', ', '')) : ?>
							<span><img src="<?php bloginfo('stylesheet_directory') ?>/images/tag.png" alt="<?php _e("Tags:", 'codelog') ?>" title="<?php _e("Tags", 'codelog') ?>" />&nbsp;<?php echo $tags ?></span>
						<?php endif; ?>

					<?php endif; ?>

				</p>
			
		</div>

	<?php endwhile; ?>

	<?php comments_template(); ?>

	<?php if (is_single()) : ?>
		<div class="navigation">
			<div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
			<div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
		</div>
	<?php elseif (is_archive() || is_home()) : ?>
		<div class="navigation">
			<div class="alignleft"><?php next_posts_link( __('&laquo; Older') ) ?></div>
			<div class="alignright"><?php previous_posts_link( __('Newer &raquo;') ) ?></div>
		</div>
	<?php endif; ?>

<?php else : ?>
<div class="post"><h2 class="posttitle"><?php _e("Error", 'codelog') ?></h2>
<p class="entry"><?php _e("Unfortunately, no content was found matching your criteria.", 'codelog') ?>
</div>
<?php endif; ?>

</div> <!--content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>